package vip.zhenzicheng.nettyadv.server.asyncpro;

import io.netty.util.NettyRuntime;

import java.util.concurrent.*;
import java.util.logging.Logger;

/**
 * 某些消息可以异步处理，例如ONE_WAY类型消息
 *
 * @author zhenzicheng
 * @date 2022-06-14 10:04
 */
public class AsyncBusyProcess {

  private static final Logger LOG = Logger.getLogger(AsyncBusyProcess.class.getSimpleName());

  private static BlockingQueue<Runnable> taskQueue = new ArrayBlockingQueue<>(3000);
  private static ExecutorService executorService = new ThreadPoolExecutor(1,
      NettyRuntime.availableProcessors(), 60, TimeUnit.SECONDS, taskQueue);

  public static void submitTask(Runnable task) {
    executorService.execute(task);
  }
}
